// orderStatus全部状态
export const xjdorderStatus: any[] = [
  {
    label: "全部",
    number: 0,
    key: -1,
  },
  {
    label: "草稿",
    status: "default",
    number: 0,
    key: 1,
  },
  {
    label: "审批中",
    status: "processing",
    number: 0,
    key: 2,
  },
  {
    label: "审批通过",
    status: "success",
    number: 0,
    key: 3,
  },
  {
    label: "审批拒绝",
    status: "error",
    number: 0,
    key: 4,
  },
  {
    label: "已付款",
    status: "success",
    number: 0,
    key: 6,
  },
  {
    label: "已退回",
    status: "error",
    number: 0,
    key: 7,
  },
  {
    label: "未开始",
    status: "error",
    number: 0,
    key: 11,
  },
  {
    label: "待接收",
    status: "processing",
    number: 0,
    key: 12,
  },
  {
    label: "内部审批中",
    status: "processing",
    number: 0,
    key: 13,
  },
  {
    label: "内部审批通过",
    status: "success",
    number: 0,
    key: 14,
  },
  {
    label: "内部审批拒绝",
    status: "error",
    number: 0,
    key: 15,
  },
  {
    label: "内部审批退回",
    status: "error",
    number: 0,
    key: 16,
  },
  {
    label: "已接收",
    status: "success",
    number: 0,
    key: 17,
  },
  {
    label: "已退回", // 重新发起
    status: "success",
    number: 0,
    key: 20,
  },
  {
    label: "待发布",
    status: "processing",
    number: 0,
    key: 51,
  },
  {
    label: "已发布",
    status: "success",
    number: 0,
    key: 52,
  },
  {
    label: "未生效",
    status: "error",
    number: 0,
    key: 53,
  },
  {
    label: "已生效",
    status: "success",
    number: 0,
    key: 54,
  },
  {
    label: "待接单",
    status: "processing",
    number: 0,
    key: 55,
  },
  {
    label: "已退回",
    status: "error",
    number: 0,
    key: 56,
  },
  {
    label: "待接受",
    status: "processing",
    number: 0,
    key: 57,
  },
  {
    label: "已作废",
    status: "error",
    number: 0,
    key: 58,
  },
  {
    label: "已接受",
    status: "success",
    number: 0,
    key: 59,
  },
  {
    label: "进行中",
    status: "processing",
    number: 0,
    key: 60,
  },
  {
    label: "已结束",
    status: "error",
    number: 0,
    key: 61,
  },
  {
    label: "对方审批中",
    status: "processing",
    number: 0,
    key: 62,
  },
  {
    label: "待对方接收",
    status: "processing",
    number: 0,
    key: 63,
  },
  {
    label: "待确认",
    status: "processing",
    number: 0,
    key: 64,
  },
  {
    label: "已确认",
    status: "success",
    number: 0,
    key: 65,
  },

  {
    label: "待对方确认",
    status: "processing",
    number: 0,
    key: 66,
  },
];

export const getApproveStatusBadge = (
  approveStatus: number,
  data: any[],
  props: object = {}
) => {
  const curProps = {
    status: "status",
    label: "label",
    key: "key",
  };
  if (props) {
    Object.assign(curProps, props);
  }
  let itemVal: any = null;
  if (data && data.length > 0) {
    data.some((item) => {
      if (item[curProps.key] == approveStatus) {
        itemVal = item;
        return true;
      }
      return false;
    });
  }
  return itemVal;
};

export const getApproveIconUrl = (dataInfo?: any) => {
  if (!dataInfo || !dataInfo.orderStatus) {
    return "";
  }

  if (dataInfo.cancelStatus == 2) {
    return `/public/scm/已作废.svg`;
  }

  return `/public/scm/${
    getApproveStatusBadge(Number(dataInfo.orderStatus), xjdorderStatus).label
  }.svg`;
};
